﻿local canlib = require("canlib")
local ERR = canlib.ERR
local dev = {
    devType = canlib.devtype.VCI_USBCAN_2E_U,
    devIndex = 0,
    canIndex = 0,
    baud = 250
}
local pkg = {
    id = 0x01,
    datalen = 8,
    data = {1, 2, 3, 4, 5, 6, 7, 8},
}

id = tonumber("00" .. "1010" .. "0" .. "0110", 2)

local s = canlib.open(dev)
if s == ERR then 
    print(canlib.errmsg(dev))
end

canlib.write(dev, pkg)

while true do
    local r = canlib.read(dev)
    for _, v in ipairs(r) do
        canlib.print(v)
    end
end

print("-----end-----")
io.read()
